package edu.wpi.cs509.clientlogic;

import edu.wpi.cs509.representation.ClientGame;
import edu.wpi.cs509.ui.intfc.ClientLogicNotify;
import edu.wpi.cs509.ui.intfc.GameEventNotify;

/**
 * The ClientLogic class 
 * 
 * The ClientLogic class keeps track of the state that is needed by the GUI.
 * It will be accessed via the ClientDownstreamLogic
 * and ClientUpstreamLogic.
 * 
 * @author jadelorie
 * @author lwante
 * @author mjsanchez
 */
public class ClientLogic {
      //Constructor is private 
      private ClientLogic() {}
      
      private static class ClientLogicSingleton {
            public static final ClientLogic instance = new ClientLogic();
      }
      
      public static ClientLogic getInstance() {
            return ClientLogicSingleton.instance;
      }
      
      /** The user session associated with this client logic object **/
      private UserSession clientSession;
      
      /** GUI Handle for GameEvents */
      private GameEventNotify gameEventHandle;
  	
  	  /** GUI Handle for sessionEvents */
  	  private ClientLogicNotify sessionEventHandle;

  	  //The gameboard to manipulate
  	  private ClientGame game;
  	
      /**
       * Get the userSession
       * 
       * @return clientSession
       */
      public UserSession getUserSession() {
            return this.clientSession;
      }
      
      /**
       * Set the userSession
       * 
       * @param clientSess - the new UserSession
       */
      public void setUserSession(UserSession clientSess) {
            this.clientSession = clientSess;
      }
      
      /**
       * Set the gameHandle
       * 
       * @param gameHandle - the gameHandle to set
       */
      public void setGameEventHandle(GameEventNotify gameHandle) {
  			this.gameEventHandle = gameHandle;
      }
  	
      /**
       * Returns the current gameHandle
       * 
       * @return
       */
      public GameEventNotify getGameEventHandle() {
  			return this.gameEventHandle;
      }
  	
      /**
       * Set the session handler
       * 
       * @param notify
       */
      public void setSessionEventHandle(ClientLogicNotify notify) {
  			this.sessionEventHandle = notify;
      }
  	
      /**
       * Returns the session handler
       * 
       * @return
       */
      public ClientLogicNotify getSessionEventHandle() {
  			return this.sessionEventHandle;
      }
      
      /**
       * Get the userSession
       * 
       * @return clientSession
       */
      public ClientGame getGame() {
            return this.game;
      }
      
      /**
       * Set the userSession
       * 
       * @param clientSess - the new UserSession
       */
      public void setGame(ClientGame clientGame) {
            this.game= clientGame;
      }
}

